home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / VarChar.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  2.1 KB  |  54 lines

  1. package symantec.itools.db.net;
  2.  
  3. import java.io.DataInputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.IOException;
  6. import symjava.sql.SQLException;
  7.  
  8. public class VarChar extends CharField {
  9.    VarChar() {
  10.    }
  11.  
  12.    int getType() {
  13.       return 73;
  14.    }
  15.  
  16.    void write(DataOutputStream out) throws IOException {
  17.       super.write(out);
  18.       NetString s = new NetString(super._data);
  19.       s.write(out);
  20.       EOT eot = new EOT();
  21.       eot.write(out);
  22.    }
  23.  
  24.    void read(DataInputStream in) throws SQLException, IOException, ErrorException {
  25.       super.read(in);
  26.       if (!super._null) {
  27.          ServerObject obj = (ServerObject)NetClass.getNextObject(in);
  28.          if (obj.getType() == 52) {
  29.             super._data = ((NetString)obj).toString();
  30.          } else {
  31.             ((ServerObject)this).onObjectError(obj);
  32.          }
  33.       }
  34.  
  35.       ServerObject obj = (ServerObject)NetClass.getNextObject(in);
  36.       if (obj.getType() != 50) {
  37.          ((ServerObject)this).onObjectError(obj);
  38.       }
  39.  
  40.    }
  41.  
  42.    public int getSQLType() {
  43.       return 12;
  44.    }
  45.  
  46.    public Object getObject() throws SQLException {
  47.       return ((CharField)this).getString();
  48.    }
  49.  
  50.    public void setObject(Object obj) throws SQLException {
  51.       ((CharField)this).setString((String)obj);
  52.    }
  53. }
  54.